<template>
  <el-container direction="vertical" style="padding: 10px">
    <el-form size="mini">
      <el-form-item label="标题">
        <el-input placeholder="请输入问题标题" v-model="formData.title"></el-input>
      </el-form-item>
      <el-form-item label="请选择模块">
        <el-select v-model="formData.moduleId" filterable placeholder="请选择">
          <el-option
            v-for="item in modules"
            :key="item.id"
            :label="item.moduleName"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="问题内容">
        <tinymce v-model="formData.content" :height="370"></tinymce>
      </el-form-item>
      <el-form-item style="text-align: right">
        <el-button @click="handleSubmit" type="primary">提交</el-button>
      </el-form-item>
    </el-form>
  </el-container>
</template>

<script>
  import Tinymce from "../../../components/Tinymce/index";
  export default {
    name: "index",
    components: {Tinymce},
    data: function () {
      return {
        modules: [],
        formData: {
          title: "",
          content: "",
          moduleId: "",
        }
      }
    },
    methods: {
      getModuleList() {
        this.$api.moduleList().then(res => {
          this.modules = res;
        })
      },
      handleSubmit() {
        this.$api.questionAdd(this.formData).then(res =>{
          console.log(res)
        })
      }
    },
    created() {
      this.getModuleList()
    }
  }
</script>

<style scoped>

</style>
